list1 = [i for i in range(1, 11)]
print(list1)
# 步长
list2 = [i for i in range(2, 21, 2)]
print(list2)
# if
list3 = [i for i in range(2, 21) if i % 2 == 0]
print(list3)
# 多个for
list4 = [(i, j) for i in range(0, 3) for j in range(0, 3)]
print(list4)

# dict1= {'id': 1, 'name':'pan'}
dict1 = {key: key ** 2 for key in range(1, 6)}
print(dict1)

li1 = ['name', 'age', 'gender']
li2 = ['tom', 20, 'male']
dict2 = {li1[i]: li2[i] for i in range(len(li1))}
print(dict2)

counts = {'MBP': 268, 'HP': 125, 'DELL': 201, 'lenovo': 199, 'acer': 99}
dict3 = {key: value for key, value in counts.items() if value >= 200}
print(dict3)

li3 = [1, 1, 2]
set1 = {i ** 2 for i in li3}
# 集合特点 ，无序。元素不重复
print(set1)

name = ['tom', 'lily', 'jacks', 'Pe', 'Steven']
set2 = {name[i] for i in range(len(name)) if len(name[i]) > 3}
print(set2)

list1 = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
li2 = [e[-1] for e in list1]
print(li2)

dict1 = {'name': '张三', 'salary': 6000}
dict2 = {'name': '李四', 'salary': 8000}
dict3 = {'name': '王五', 'salary': 4000}
dict4 = {'name': '吴二', 'salary': 3000}
list2 = [dict1, dict2, dict3, dict4]
# e是一个字典 比如：{'name': '张三', 'salary': 6000}
# 取出工资 e['salary']
# 工资>5000的人加200，否则加500
li2 = [(e['name'],e['salary'] + 200) if e['salary'] > 5000 else (e['name'],e['salary'] + 500) for e in list2]
print(li2)


scores = {
      "Rick Sanchez": 70,
      "Morty Smith": 35,
      "Summer Smith": 82,
      "Jerry Smith": 23,
      "Beth Smith": 98
    }

li2 = {key:value for (key,value) in scores.items() if value<60}
print(li2)

//
